<template>
  <div class="total-container">
    <div class="common-tab-box">
      <div
        class="tab"
        v-for="item in tabs"
        :class="{ active: currentSelectedId === item.id }"
        :key="item.id"
        @click="handleClick(item.id)"
      >
        {{ item.text }}
      </div>
    </div>
    <div class="comp-box">
      <component :is="compName"></component>
    </div>
  </div>
</template>
<script>
import industrialInjury from './tabComp/industrialInjury.vue'
import unemployment from './tabComp/unemployment.vue'
export default {
  data() {
    return {
      tabs: [
        { text: '工伤', id: 0, compName: 'industrialInjury' },
        { text: '失业', id: 1, compName: 'unemployment' }
      ],
      currentSelectedId: 0,
      compName: 'industrialInjury'
    }
  },
  components: {
    industrialInjury,
    unemployment
  },
  methods: {
    handleClick(id) {
      this.currentSelectedId = id
      this.compName = this.tabs[id].compName
    }
  }
}
</script>
<style lang="scss" scoped>
.total-container {
  .common-tab-box {
    margin-top: 10px;
  }
  .comp-box {
    height: 200px;
  }
}
</style>
